<?php
/**
 * Created by PhpStorm.
 * User: steven
 * Date: 2017/11/18
 * Time: 下午8:31
 */

namespace app\api\validate;


class IDCollection extends BaseValidate {

    protected $rule = [
        'ids'  => 'require|checkIDs',
    ];

    protected $message = [
        'ids' => "ids参数是必须以逗号分隔的多个正整数"
    ];

    //ids = id1,id2,
    protected function checkIDs($value){
        $value = explode(',',$value);
        if(empty($value)){
            return false;
        }

        foreach ($value as $id){
            if(!$this->isPositiveInteger($id)){
                return false;
            }
        }
        return true;
    }
}